#include <iostream>
#include <pthread.h>
#include <unistd.h>
using namespace std;

__thread int global_val = 100;

void *Routine(void *argv)
{
    const char* name = static_cast<const char*>(argv);
    while(true)
    {
        cout<<"thread: "<<name<<"  global_value"<<global_val<<" new: "<<global_val++<<"address: "<<&global_val<<endl;
        sleep(1);
    }
}

int main()
{
    pthread_t tid1;
    pthread_t tid2;
    pthread_t tid3;
    pthread_create(&tid1,nullptr,Routine,(void*)"thread1");
    pthread_create(&tid2,nullptr,Routine,(void*)"thread2");
    pthread_create(&tid3,nullptr,Routine,(void*)"thread3");
    pthread_join(tid1,nullptr);
    pthread_join(tid2,nullptr);
    pthread_join(tid3,nullptr);
    return 0;
}